<?php echo $header; ?>
	<section class="main">
    	<section class="product">
        	<section class="product-info">
            	<div class="container">
                	<div class="row">
                    	<div class="span4">
                        	<div class="product-images">
                            	<div class="box">
                                	<div class="primary">
                                    	<img src="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" />
                                    </div>
                                    <div class="thumbs" id="gallery">
                                          <ul class="thumbs-list">
                                          		<li>
                                                  <a  data-image="<?php echo $popup?>" href="<?php echo $thumb; ?>" title="<?php echo $heading_title; ?>" data-zoom-image="<?php echo $popup?>">
                                                      <img src="<?php echo $thumb?>" alt="<?php echo $heading_title; ?>">
                                                  </a>
                                              </li>
                                          	  <?php if(!empty($images)){ foreach($images as $image){?>
                                              <li>
                                                  <a  data-image="<?php echo $image['popup']; ?>" href="<?php echo $image['thumb']; ?>" title="<?php echo $heading_title; ?>" data-zoom-image="<?php echo $image['popup']; ?>">
                                                      <img src="<?php echo $image['thumb']; ?>" alt="<?php echo $heading_title; ?>">
                                                  </a>
                                              </li>
                                              <?php }}?>
                                          </ul>
									</div>
                                    <div class="social">
                                    	<div id="sharrre">
                                        	<div class="facebook sharrre">
                                            	<button class="btn btn-mini btn-facebook">
                                                	<i class="icon-facebook"> &nbsp; 0</i>
                                                </button>
                                            </div>
                                            <div class="twitter sharrre">
                                            	<button class="btn btn-mini btn-twitter">
                                                	<i class="icon-twitter"> &nbsp; 0</i>
                                                </button>
                                            </div>
                                            <div class="googleplus sharrre"></div>
                                            <div class="pinterest sharrre">
                                            	<button class="btn btn-mini btn-pinterest">
                                                	<i class="icon-pinterest"> &nbsp; 0</i>
                                                </button>
                                            </div>
                                        </div>
                                    </div><!-- social -->
                                </div><!-- box -->
                            </div><!-- product-images -->
                        </div><!-- span4 -->
                        <div class="span8">
                        	<div class="product-content">
                            	<div class="box">
                                	<ul class="nav nav-tabs">
                                    	<li class="active">
                                            <a href="#product" data-toggle="tab">
                                            	<i class="icon-reorder icon-large"></i>
                                                <span class="hidden-phone"><?php echo $text_product ?></span>
                                            </a>
                                        </li>
										<li>
                                        	<a href="#tab-description" data-toggle="tab"><i class="icon-info-sign icon-large"></i><span class="hidden-phone">
                                            	<?php echo $tab_description; ?></span></a>
                                        </li>
                                        <?php if ($attribute_groups) { ?>
                                        	<li>
                                            	<a href="#tab-specification" data-toggle="tab"><i class="icon-info-sign icon-large"></i><?php echo $tab_attribute; ?></a>
                                            </li>
										<?php } ?>
                                         <?php if ($review_status) { ?>
                                            <li><a href="#tab-review" data-toggle="tab"><i class="icon-heart icon-large"></i><?php echo $tab_review;?></a></li>
                                        <?php } ?>
                                    </ul>
                                    <div class="tab-content">
                                    	<div class="tab-pane active" id="product">
                                        	<form>
                                       		<div class="details">
                                            	<h1><?php echo $heading_title?></h1>
                                                <?php if ($price) { ?>
                                                    <ul class="list-unstyled prices">
                                                        <?php if (!$special) { ?>
                                                        <li>
                                                          <span class="price"><?php echo $price; ?></span>
                                                        </li>
                                                        <?php } else { ?>
                                                        <li><span style="text-decoration: line-through;"><?php echo $price; ?></span></li>
                                                        <li>
                                                          <span class="price"><?php echo $special; ?></span>
                                                        </li>
                                                        <?php } ?>
                                                        <?php if ($tax) { ?>
                                                        	<li><?php echo $text_tax; ?> <?php echo $tax; ?></li>
                                                        <?php } ?>
                                                        <?php if ($points) { ?>
                                                        	<li><?php echo $text_points; ?> <?php echo $points; ?></li>
                                                        <?php } ?>
                                                        <?php if ($discounts) { ?>
                                                        <?php foreach ($discounts as $discount) { ?>
                                                        <li><?php echo $discount['quantity']; ?><?php echo $text_discount; ?><?php echo $discount['price']; ?></li>
                                                        <?php } ?>
                                                        <?php } ?>
                                                    </ul>
                                                <?php }?>
                                                <div class="meta">
                                                	<div class="sku">
                                                    	<i class="icon-pencil"></i>
                                                        <span rel="tooltip" title="" data-original-title="<?php echo $model?>"><?php echo $model?></span>
                                                    </div>
                                                    <div class="categories">
                                                    	<i class="icon-tags"></i>
                                                        <?php if ($tags) { ?>
                                                              <?php for ($i = 0; $i < count($tags); $i++) { ?>
                                                              <?php if ($i < (count($tags) - 1)) { ?>
                                                              	<a href="<?php echo $tags[$i]['href']; ?>"><?php echo $tags[$i]['tag']; ?></a>,
                                                              <?php } else { ?>
                                                             	 <a href="<?php echo $tags[$i]['href']; ?>"><?php echo $tags[$i]['tag']; ?></a>
                                                              <?php } ?>
                                                              <?php } ?>
                                                        <?php } ?>
                                                    </div>
                                                </div>
                                            </div><!-- details -->
                                            <?php if(!empty($meta_description)){?>
                                            <div class="short-description">
                                            	<?php echo $meta_description?>
                                            </div><!-- short-description -->
                                            <?php }?>
                                            <div class="options">
                                            	<?php if(!empty($options)) foreach ($options as $option) { ?>
                                                    <?php if ($option['type'] == 'select') { ?>
                                                    <div class="form-group<?php echo ($option['required'] ? ' required' : ''); ?>">
                                                      <label class="control-label" for="input-option<?php echo $option['product_option_id']; ?>"><?php echo $option['name']; ?></label>
                                                      <select name="option[<?php echo $option['product_option_id']; ?>]" id="input-option<?php echo $option['product_option_id']; ?>" class="form-control">
                                                        <option value=""><?php echo $text_select; ?></option>
                                                        <?php foreach ($option['product_option_value'] as $option_value) { ?>
                                                        <option value="<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
                                                        <?php if ($option_value['price']) { ?>
                                                        (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
                                                        <?php } ?>
                                                        </option>
                                                        <?php } ?>
                                                      </select>
                                                    </div>
                                                    <?php } ?>
                                                    <?php if ($option['type'] == 'radio') { ?>
                                                    <div class="form-group<?php echo ($option['required'] ? ' required' : ''); ?>">
                                                      <label class="control-label"><?php echo $option['name']; ?></label>
                                                      <div id="input-option<?php echo $option['product_option_id']; ?>">
                                                        <?php foreach ($option['product_option_value'] as $option_value) { ?>
                                                        <div class="radio">
                                                          <label>
                                                            <input type="radio" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option_value['product_option_value_id']; ?>" />
                                                            <?php echo $option_value['name']; ?>
                                                            <?php if ($option_value['price']) { ?>
                                                            (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
                                                            <?php } ?>
                                                          </label>
                                                        </div>
                                                        <?php } ?>
                                                      </div>
                                                    </div>
                                                    <?php } ?>
                                                    <?php if ($option['type'] == 'checkbox') { ?>
                                                    <div class="form-group<?php echo ($option['required'] ? ' required' : ''); ?>">
                                                      <label class="control-label"><?php echo $option['name']; ?></label>
                                                      <div id="input-option<?php echo $option['product_option_id']; ?>">
                                                        <?php foreach ($option['product_option_value'] as $option_value) { ?>
                                                        <div class="checkbox">
                                                          <label>
                                                            <input type="checkbox" name="option[<?php echo $option['product_option_id']; ?>][]" value="<?php echo $option_value['product_option_value_id']; ?>" />
                                                            <?php echo $option_value['name']; ?>
                                                            <?php if ($option_value['price']) { ?>
                                                            (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
                                                            <?php } ?>
                                                          </label>
                                                        </div>
                                                        <?php } ?>
                                                      </div>
                                                    </div>
                                                    <?php } ?>
                                                    <?php if ($option['type'] == 'image') { ?>
                                                    <div class="form-group<?php echo ($option['required'] ? ' required' : ''); ?>">
                                                      <label class="control-label"><?php echo $option['name']; ?></label>
                                                      <div id="input-option<?php echo $option['product_option_id']; ?>">
                                                        <?php foreach ($option['product_option_value'] as $option_value) { ?>
                                                        <div class="radio">
                                                          <label>
                                                            <input type="radio" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option_value['product_option_value_id']; ?>" />
                                                            <img src="<?php echo $option_value['image']; ?>" alt="<?php echo $option_value['name'] . ($option_value['price'] ? ' ' . $option_value['price_prefix'] . $option_value['price'] : ''); ?>" class="img-thumbnail" /> <?php echo $option_value['name']; ?>
                                                            <?php if ($option_value['price']) { ?>
                                                            (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
                                                            <?php } ?>
                                                          </label>
                                                        </div>
                                                        <?php } ?>
                                                      </div>
                                                    </div>
                                                    <?php } ?>
                                                    <?php if ($option['type'] == 'text') { ?>
                                                    <div class="form-group<?php echo ($option['required'] ? ' required' : ''); ?>">
                                                      <label class="control-label" for="input-option<?php echo $option['product_option_id']; ?>"><?php echo $option['name']; ?></label>
                                                      <input type="text" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option['value']; ?>" placeholder="<?php echo $option['name']; ?>" id="input-option<?php echo $option['product_option_id']; ?>" class="form-control" />
                                                    </div>
                                                    <?php } ?>
                                                    <?php if ($option['type'] == 'textarea') { ?>
                                                    <div class="form-group<?php echo ($option['required'] ? ' required' : ''); ?>">
                                                      <label class="control-label" for="input-option<?php echo $option['product_option_id']; ?>"><?php echo $option['name']; ?></label>
                                                      <textarea name="option[<?php echo $option['product_option_id']; ?>]" rows="5" placeholder="<?php echo $option['name']; ?>" id="input-option<?php echo $option['product_option_id']; ?>" class="form-control"><?php echo $option['value']; ?></textarea>
                                                    </div>
                                                    <?php } ?>
                                                    <?php if ($option['type'] == 'file') { ?>
                                                    <div class="form-group<?php echo ($option['required'] ? ' required' : ''); ?>">
                                                      <label class="control-label"><?php echo $option['name']; ?></label>
                                                      <button type="button" id="button-upload<?php echo $option['product_option_id'];?>" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-default btn-block"><i class="fa fa-upload"></i> <?php echo $button_upload; ?></button>
                                                      <input type="hidden" name="option[<?php echo $option['product_option_id']; ?>]" value="" id="input-option<?php echo $option['product_option_id']; ?>" />
                                                    </div>
                                                    <?php } ?>
                                                    <?php if ($option['type'] == 'date') { ?>
                                                    <div class="form-group<?php echo ($option['required'] ? ' required' : ''); ?>">
                                                      <label class="control-label" for="input-option<?php echo $option['product_option_id']; ?>"><?php echo $option['name']; ?></label>
                                                      <div class="input-group ">
                                                        <input  type="text" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option['value']; ?>" data-format="YYYY-MM-DD" id="input-option<?php echo $option['product_option_id']; ?>" class="form-control date" />
                                                      </div>
                                                    </div>
                                                    <?php } ?>
                                                    <?php if ($option['type'] == 'datetime') { ?>
                                                    <div class="form-group<?php echo ($option['required'] ? ' required' : ''); ?>">
                                                      <label class="control-label" for="input-option<?php echo $option['product_option_id']; ?>"><?php echo $option['name']; ?></label>
                                                          <div class="input-group ">
                                                            <input  type="text" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option['value']; ?>" data-format="YYYY-MM-DD HH:mm" id="input-option<?php echo $option['product_option_id']; ?>" class="form-control datetime" />
                                                         </div>
                                                    </div>
                                                    <?php } ?>
                                                    <?php if ($option['type'] == 'time') { ?>
                                                    <div class="form-group<?php echo ($option['required'] ? ' required' : ''); ?>">
                                                      <label class="control-label" for="input-option<?php echo $option['product_option_id']; ?>"><?php echo $option['name']; ?></label>
                                                      <div class="input-group ">
                                                        <input type="text" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option['value']; ?>" data-format="HH:mm" id="input-option<?php echo $option['product_option_id']; ?>" class="form-control time" />
                                                        <span class="input-group-btn">
                                                        <i class="fa fa-calendar"></i>
                                                        </span></div>
                                                    </div>
                                                    <?php } ?>
                                                    <?php } ?>
                                            </div>
											<div class="add-to-cart">
                                            <label class="control-label" for="input-quantity"><?php echo $entry_qty; ?></label>
             								<input type="text" name="quantity" value="<?php echo $minimum; ?>" size="2" id="input-quantity" class="form-control" />
                                            <input type="hidden" name="product_id" value="<?php echo $product_id; ?>" />
                                             <br />
                                            	 <button type="button" id="button-cart" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-primary btn-lg btn-block"><?php echo $button_cart; ?></button>
                                            </div><!-- add-to-cart -->
                                            </form>
                                        </div><!-- tab-pane active -->
                                        <div class="tab-pane" id="tab-description">
                                        	<?php echo $description?>
                                        </div>
                                        <?php if ($review_status) { ?>
                  						<div class="tab-pane" id="tab-review">
											<form class="form-horizontal">
               								 <div id="review"></div>
                                             <div class="well">
                                             	<div class="row-fluid">
                                                	<div class="span8">
                                                    	<h6><i class="icon-comment-alt"></i> &nbsp; Share your opinion!</h6>
                                                        <p>Let other people know your thoughts on this product!</p>
                                                    </div>
                                                    <div class="span4">
                                                    	<button class="btn btn-seconary btn-block" onclick="$('#review_form').modal('show');return false;">Rate this product</button>
                                                    </div>
                                                </div>
                                             </div>
                                             <div id="review_form" class="modal hide fade" tabindex="-1" role="dialog">
                                             	<div class="modal-header">
                                                	<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                                    <div class="hgroup title">
                                                    	<h3><?php echo $text_write; ?></h3>
                                                    </div>
                                                </div><!-- modal-header -->
                                                <div class="modal-body">
                                                	<div class="review_dialog"></div>
                                                	<div class="row-fluid">
                                                        <div class="span6">
                                                        	<div class="control-group">
                                                            	<label class="control-label"><?php echo $entry_rating; ?></label>
                                                                <div class="controls" style="margin-left:auto">
                                                                	<select name="rating" class="span12" >
                                                                    	<option value=""> --- <?php echo $entry_rating; ?> --- </option>
                                                                        <option value="1"> 1 </option>
                                                                        <option value="1"> 2 </option>
                                                                        <option value="1"> 3 </option>
                                                                        <option value="1"> 4 </option>
                                                                        <option value="1"> 5 </option>
                                                                    </select>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="span6">
                                                        	<div class="control-group">
                                                            	<label class="control-label"><?php echo $entry_name; ?></label>
                                                                <div class="controls" style="margin-left:auto"><input type="text" name="name" value="" id="input-name" class="span12" /></div>
                                                            </div>
                                                        </div>
                                                    </div><!-- row-fluid -->
                                                    <div class="row-fluid">
                                                    	<div class="span12">
                                                        	<div class="control-group">
                                                            	<label class="control-label"><?php echo $entry_review; ?></label>
                                                                <div class="controls" style="margin-left:auto"><textarea name="text" rows="5" id="input-review" class="span12"></textarea></div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                     <div class="row-fluid">
                                                     	<div class="span6">
                                                        	<div class="control-group">
                                                            	<label class="control-label"><?php echo $entry_captcha; ?></label>
                                                                <div class="controls" style="margin-left:auto"> <input type="text" name="captcha" value="" id="input-captcha" class="span12" /></div> 
                                                            </div>
                                                        </div>
                                                        <div class="span6"><div class="control-group"><div class="controls" style="margin-left:auto;padding-top:20px"><img src="index.php?route=tool/captcha" alt="" id="captcha" /></div></div></div>
                                                        
                                                     </div>
                                                </div><!-- modal-body -->
                                                <div class="modal-footer">
                                                	<div class="pull-right">
                                                    	 <button type="button" id="button-review" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-primary"><?php echo $button_continue; ?></button>
                                                    </div>
                                                </div>
                                             </div>
              								</form>
                                        </div><!-- tab-pane -->
                                        <?php }?>
                                    </div><!-- tab-content -->
                                </div><!-- box -->
                            </div><!-- product-conten -->
                        </div><!-- span8 -->
                    </div><!-- row -->
                </div>
            </section>
        </section>
    </section>
<?php echo $footer; ?>
<script language="javascript">
$().ready(function(){
$('select[name=\'recurring_id\'], input[name="quantity"]').change(function(){
	$.ajax({
		url: 'index.php?route=product/product/getRecurringDescription',
		type: 'post',
		data: $('input[name=\'product_id\'], input[name=\'quantity\'], select[name=\'recurring_id\']'),
		dataType: 'json',
		beforeSend: function() {
			$('#recurring-description').html('');
		},
		success: function(json) {
			$('.alert, .text-danger').remove();
			
			if (json['success']) {
				$('#recurring-description').html(json['success']);
			}
		}
	});
});

$('#button-cart').on('click', function() {
	$.ajax({
		url: 'index.php?route=checkout/cart/add',
		type: 'post',
		data: $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea'),
		dataType: 'json',
		beforeSend: function() {
			$('#button-cart').button('loading');
		},
		complete: function() {
			$('#button-cart').button('reset');
		},
		success: function(json) {
			$('.alert, .text-danger').remove();
			$('.form-group').removeClass('has-error');

			if (json['error']) {
				if (json['error']['option']) {
					for (i in json['error']['option']) {
						var element = $('#input-option' + i.replace('_', '-'));
						
						if (element.parent().hasClass('input-group')) {
							element.parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
						} else {
							element.after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
						}
					}
				}
				
				if (json['error']['recurring']) {
					$('select[name=\'recurring_id\']').after('<div class="text-danger">' + json['error']['recurring'] + '</div>');
				}
				
				// Highlight any found errors
				$('.text-danger').parent().addClass('has-error');
			}
			if (json['success']) {
				$('.breadcrumb').after('<div class="alert alert-success">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');
				
				$('#cart-total').html(json['total']);
				
				$('html, body').animate({ scrollTop: 0 }, 'slow');
				
				$('#cart > ul').load('index.php?route=common/cart/info ul li');
			}
		}
	});
});
$('.date').datetimepicker({
	pickTime: false,timepicker:false,
});

$('.datetime').datetimepicker({
	pickDate: true,
	pickTime: true,timepicker:false,
});

$('.time').datetimepicker({
	pickDate: false,timepicker:false,
});
$('button[id^=\'button-upload\']').on('click', function() {

	var node = this;
	
	$('#form-upload').remove();
	
	$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>');
	
	$('#form-upload input[name=\'file\']').trigger('click');
	
	$('#form-upload input[name=\'file\']').on('change', function() {
		$.ajax({
			url: 'index.php?route=tool/upload',
			type: 'post',
			dataType: 'json',
			data: new FormData($(this).parent()[0]),
			cache: false,
			contentType: false,
			processData: false,
			beforeSend: function() {
				$(node).button('loading');
			},
			complete: function() {
				$(node).button('reset');
			},
			success: function(json) {
				$('.text-danger').remove();
				
				if (json['error']) {
					$(node).parent().find('input').after('<div class="text-danger">' + json['error'] + '</div>');
				}
				
				if (json['success']) {
					alert(json['success']);
					
					$(node).parent().find('input').attr('value', json['code']);
				}
			},
			error: function(xhr, ajaxOptions, thrownError) {
				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
			}
		});
	});
});
$('#review').delegate('.pagination a', 'click', function(e) {
  e.preventDefault();

    $('#review').fadeOut('slow');

    $('#review').load(this.href);

    $('#review').fadeIn('slow');
});

$('#review').load('index.php?route=product/product/review&product_id=<?php echo $product_id; ?>');

$('#button-review').on('click', function() {
	$.ajax({
		url: 'index.php?route=product/product/write&product_id=<?php echo $product_id; ?>',
		type: 'post',
		dataType: 'json',
		data: 'name=' + encodeURIComponent($('input[name=\'name\']').val()) + '&text=' + encodeURIComponent($('textarea[name=\'text\']').val()) + '&rating=' + encodeURIComponent($('select[name=\'rating\']').val() ? $('select[name=\'rating\']').val() : '') + '&captcha=' + encodeURIComponent($('input[name=\'captcha\']').val()),
		beforeSend: function() {
			$('#button-review').button('loading');
		},
		complete: function() {
			$('#button-review').button('reset');
			$('#captcha').attr('src', 'index.php?route=tool/captcha#'+new Date().getTime());
			$('input[name=\'captcha\']').val('');
		},
		success: function(json) {
			$('.alert-success, .alert-danger').remove();
			if (json['error']) {
				$('.review_dialog').html('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + '</div>');
			}
			
			if (json['success']) {
				$('.review_dialog').html('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + '</div>');
				$('input[name=\'name\']').val('');
				$('textarea[name=\'text\']').val('');
				$('select[name=\'rating\']').prop('checked', false);
				$('input[name=\'captcha\']').val('');
			}
			
		}
	});
});

});
</script>